﻿<!--
Copyright © Pavel Fedarovich, 2010-2012

This file is part of AvalonWizard.
 
You may at your option receive a license to Avalon Wizard under 
either the terms of the Apache License version 2.0 or 
the GNU Lesser General Public License (LGPL) version 2.1 or any later version.
 
AvalonWizard is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
You may obtain a copy of the Apache License at [http://www.apache.org/licenses/LICENSE-2.0].
You may obtain a copy of the LGPL at [http://www.gnu.org/licenses/].
-->
<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:AvalonWizard" 
    xmlns:conv="clr-namespace:AvalonWizard.Converters" 
    xmlns:s="clr-namespace:System;assembly=mscorlib">

    <conv:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    <conv:BooleanInverterConvertor x:Key="BooleanInverter" />
    <conv:VisibilityMultiConverter x:Key="VisibilityMultiConverter" />

    <Style TargetType="{x:Type local:WizardPage}" x:Key="Wizard97_WizardPageStyle">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:WizardPage}">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="60" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <Border Grid.Row="0" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                <ContentPresenter Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" VerticalAlignment="Center" />
                            </Border>
                            <Separator Grid.Row="1" Margin="0" />
                            <Border Grid.Row="2" Background="{TemplateBinding Background}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="{TemplateBinding Padding}">
                                <ContentPresenter />
                            </Border>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="HeaderTemplate">
            <Setter.Value>
                <DataTemplate DataType="s:String">
                    <Grid Margin="18,0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" MinHeight="16" />
                            <RowDefinition Height="Auto" MinHeight="16" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Row="0" Grid.Column="0" FontWeight="Bold" Text="{Binding}" Margin="0,10,0,1" />
                        <TextBlock Grid.Row="1" Grid.Column="0" Margin="20,1,0,1" Text="{Binding RelativeSource={RelativeSource AncestorType=local:WizardPage}, Path=(local:Wizard97.Subtitle)}" />
                        <Image Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Width="48" Height="48" VerticalAlignment="Center" Source="{Binding RelativeSource={RelativeSource AncestorType=local:WizardPage}, Path=(local:Wizard97.Icon)}" />
                    </Grid>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
    </Style>

    <ControlTemplate TargetType="{x:Type local:Wizard}" x:Key="Wizard97_ControlTemplate">
        <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
            <Grid>
                <Grid.Resources>
                    <Style TargetType="{x:Type local:WizardPage}" BasedOn="{StaticResource Wizard97_WizardPageStyle}" />
                </Grid.Resources>

                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <ContentPresenter Grid.Row="0" Content="{TemplateBinding CurrentPage}" />
                <Separator Grid.Row="1" Margin="0" />
                <Grid Grid.Row="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Grid.Resources>
                        <Style TargetType="Button">
                            <Setter Property="Margin" Value="2,10" />
                            <Setter Property="Padding" Value="12,1" />
                        </Style>
                    </Grid.Resources>
                    <Button Grid.Column="1" Content="{TemplateBinding BackButtonContent}" Command="{x:Static Member=local:WizardCommands.PreviousPage}" Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CurrentPage.ShowBack,
                                        Converter={StaticResource BooleanToVisibilityConverter}}" />
                    <Button Grid.Column="2" IsDefault="True" Content="{TemplateBinding NextButtonContent}" Command="{x:Static Member=local:WizardCommands.NextPage}">
                        <Button.Visibility>
                            <MultiBinding Converter="{StaticResource VisibilityMultiConverter}" ConverterParameter="ALL">
                                <Binding Path="IsLastPage" Converter="{StaticResource BooleanToVisibilityConverter}" ConverterParameter="INVERT">
                                    <Binding.RelativeSource>
                                        <RelativeSource Mode="TemplatedParent" />
                                    </Binding.RelativeSource>
                                </Binding>
                                <Binding Path="CurrentPage.ShowNext" Converter="{StaticResource BooleanToVisibilityConverter}">
                                    <Binding.RelativeSource>
                                        <RelativeSource Mode="TemplatedParent" />
                                    </Binding.RelativeSource>
                                </Binding>
                            </MultiBinding>
                        </Button.Visibility>
                    </Button>

                    <Button Grid.Column="3" IsDefault="True" Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=IsLastPage, 
                                        Converter={StaticResource BooleanToVisibilityConverter}}" Content="{TemplateBinding FinishButtonContent}" Command="{x:Static Member=local:WizardCommands.Finish}" />
                    <Button Grid.Column="4" IsCancel="True" Margin="10" Content="{TemplateBinding CancelButtonContent}" Command="{x:Static Member=local:WizardCommands.Cancel}" Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=CurrentPage.ShowCancel,
                                        Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=HIDE, FallbackValue=Visible}" />
                </Grid>
            </Grid>
        </Border>
    </ControlTemplate>
</ResourceDictionary>